#pragma once
#include <iostream>
#include <fcntl.h>

const int default_port = 8080;

enum LogLevel
{
    OK = 0,
    USAGE_ERR,
    SOCKET_ERR, 
    BIND_ERR, 
    LISTEN_ERR,
    ACCEPT_ERR,
    CONNECT_ERR
};

class Nocopy
{
public:
    Nocopy(){}

    ~Nocopy(){}

    Nocopy(const Nocopy& ncp) = delete;

    const Nocopy& operator=(const Nocopy& ncp) = delete;
};

void SetNonBlock(int fd)
{
    int fl = fcntl(fd, F_GETFL);
    if(fl < 0)
    {
        return; 
    }
    fcntl(fd, F_SETFL, fl | O_NONBLOCK);
}

#define CONV(addr) ((struct sockaddr*)&addr)